package com.hjm.suanfa.美团;

import java.util.Scanner;

public class MT {
    // https://www.nowcoder.com/exam/test/88247074/detail?pid=55750560&examPageSource=Company&subTabName=written_page&testCallback=https%3A%2F%2Fwww.nowcoder.com%2Fexam%2Fcompany%3FquestionJobId%3D10%26subTabName%3Dwritten_page&testclass=%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        in.nextLine();
        String s=in.nextLine();
        int count= 0;
        for(char c : s.toCharArray()){
            if(c == 'M' || c == 'T'){
                count++;
            }
        }
        int ans = Math.min(n, count + k);
        System.out.println(ans);
    }
}
